home *** CD-ROM | disk | FTP | other *** search
/ Interactive Media Design Review 1999 / Interactive Media Design Review 1999.iso / pc / Demos / Herois / Codigo.Cst / 00015_Script_Texto Drag < prev    next >
Text File  |  1999-03-19  |  2KB  |  55 lines

  1. property spr, mem
  2. property interessados
  3. property linhaAtual, linhaMax
  4. property numLinhas
  5. property alturaLinha, linhasJanela
  6.  
  7. on getPropertyDescriptionList
  8.   set p_list = [ ¼
  9.     #interessados: [ #comment:   "Sprites que se interessam pelo scroll:", ¼
  10.              #format:   #list, ¼
  11.                    #default:  [] ] ¼
  12.   ]
  13.   return p_list
  14. end
  15.  
  16. on beginSprite me
  17.   set spr = the spriteNum of me
  18.   set mem = the member of sprite spr
  19.   set linhaAtual = 1
  20.   set numLinhas = the lineCount of member mem
  21.   set alturaLinha =  lineheight(mem, 1)
  22.   set linhasJanela = the height of sprite spr / alturaLinha
  23.   set linhaMax = numLinhas - alturaLinha/2
  24.   if linhaMax < 1 then set linhaMax = 1
  25. end
  26.  
  27. on mouseDown me
  28.   set y_ini = the mouseV
  29.   set linha_ini = linhaAtual
  30.   global gCritico, gMustUpdate
  31.   set gCritico = gCritico + 1
  32.   repeat while the mouseDown
  33.     set gMustUpdate = false
  34.     sendAllSprites(#idleSprite)
  35.     set y = the mouseV
  36.     set l = - (y - y_ini) / alturaLinha + linha_ini
  37.     if l < 1 then
  38.       set l = 1
  39.     else if l > linhaMax then 
  40.       set l = linhaMax
  41.     end if
  42.     if l <> linhaAtual then
  43.       scrollByLine member mem, l-linhaAtual
  44.       set gMustUpdate = true
  45.       if count(interessados) > 0 then
  46.         repeat with i = 1 to count(interessados)
  47.           sendSprite(getAt(interessados,i), #scrollLinha, l - linhaAtual)
  48.         end repeat
  49.       end if
  50.       set linhaAtual = l
  51.     end if
  52.     if gMustUpdate then updateStage
  53.   end repeat
  54.   set gCritico = gCritico -1
  55. end